// pages/component/submit-form/2/index.js
const { $wx } = getApp()
Page({
    data: {
        formData: [
            { label:'用户', name:'user', value:'admin', r:1, min:1, max:5 },
            { label:'用户2', name:'admin', value:'admin', r:1, eq: 5 },
            { label:'用户3', name:'account', value:'account', r:1, rules: { max:7, msg:'我的用户名最大长度为 7' }},
            { label:'密码', name:'password', value:'a12345',  r:1, rules:'password', opt:{ password:true } },
            { label:'电话1', name:'phone', value:'15882463718', r:1, rules:'phone' },
            { label:'电话2', name:'phone2', value:'15882463718', r:1, rules:[{ eq: 11, msg:'电话号码长度为 11 位'}, 'phone'] },
            { label:'身份证', name:'idcard', value:'62010219861112621x', r:1, rules:'idcard'},
            { label:'邮箱',  name:'email', value:'523012325@qq.com', rules:{ reg:'email', msg:'邮箱匹配不正确' } },
            { label:'数字', name:'number', value:'123', rules:{ reg: v=> /^[0-9]+$/.test(v), msg:'只能输入数字'} },
            { label:'字母', name:'letter', value:'abc', rules:{ reg: '^[a-z]+$', attr:'g', msg:'只能输入字母'} },
        ]
    },
    onSubmit({ detail }){
        console.log(detail)
        $wx.msg.success('提交成功')
    },
    onChange({ detail }){
        console.log(detail)
    }
})